home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gnugo1_1.lha / gnugo / showbord.c < prev    next >
C/C++ Source or Header  |  1989-03-07  |  6KB  |  291 lines

  1. /*
  2.                 GNU GO - the game of Go (Wei-Chi)
  3.                 Version 1.1   last revised 3-1-89
  4.            Copyright (C) Free Software Foundation, Inc.
  5.                       written by Man L. Li
  6.                       modified by Wayne Iba
  7.                     documented by Bob Webber
  8. */
  9. /*
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation - version 1.
  13.  
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License in file COPYING for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. Please report any bug/fix, modification, suggestion to
  24.  
  25. mail address:   Man L. Li
  26.                 Dept. of Computer Science
  27.                 University of Houston
  28.                 4800 Calhoun Road
  29.                 Houston, TX 77004
  30.  
  31. e-mail address: manli@cs.uh.edu         (Internet)
  32.                 coscgbn@uhvax1.bitnet   (BITNET)
  33.                 70070,404               (CompuServe)
  34. */
  35.  
  36. #include <stdio.h>
  37.  
  38. #define EMPTY 0
  39. #define WHITE 1
  40.  
  41. extern unsigned char p[19][19];
  42. extern int mymove, umove;
  43. extern int mk, uk;  /* piece captured */
  44.  
  45. showboard()
  46. /* show go board */
  47.   {
  48.    int i, j, ii;
  49.  
  50. /* p = 0 for empty ,p = 1 for white piece, p = 2 for black piece */
  51.    printf("   A B C D E F G H J K L M N O P Q R S T\n");
  52. /* row 19 to 17 */
  53.    for (i = 0; i < 3; i++)
  54.      {
  55.       ii = 19 - i;
  56.       printf("%2d",ii);
  57.  
  58.       for (j = 0; j < 19; j++)
  59.     if (p[i][j] == EMPTY)
  60.        printf(" -");
  61.     else if (p[i][j] == WHITE)
  62.         printf(" O");
  63.          else printf(" X");
  64.  
  65.       printf("%2d",ii);
  66.       printf("\n");
  67.      }
  68. /* row 16 */
  69.    printf("16");
  70.  
  71.    for (j = 0; j < 3; j++)
  72.      if (p[3][j] == EMPTY)
  73.     printf(" -");
  74.      else if (p[3][j] == WHITE)
  75.          printf(" O");
  76.       else printf(" X");
  77.  
  78.    if (p[3][3] == 0)
  79.       printf(" +");
  80.    else if (p[3][3] == WHITE)
  81.        printf(" O");
  82.     else printf(" X");
  83.  
  84.    for (j = 4; j < 9; j++)
  85.      if (p[3][j] == EMPTY)
  86.     printf(" -");
  87.      else if (p[3][j] == WHITE)
  88.          printf(" O");
  89.       else printf(" X");
  90.  
  91.    if (p[3][9] == EMPTY)
  92.       printf(" +");
  93.    else if (p[3][9] == WHITE)
  94.        printf(" O");
  95.     else printf(" X");
  96.  
  97.    for (j = 10; j < 15; j++)
  98.      if (p[3][j] == EMPTY)
  99.     printf(" -");
  100.      else if (p[3][j] == WHITE)
  101.          printf(" O");
  102.       else printf(" X");
  103.  
  104.    if (p[3][15] == EMPTY)
  105.       printf(" +");
  106.    else if (p[3][15] == WHITE)
  107.        printf(" O");
  108.     else printf(" X");
  109.  
  110.    for (j = 16; j < 19; j++)
  111.      if (p[3][j] == EMPTY)
  112.     printf(" -");
  113.      else if (p[3][j] == WHITE)
  114.          printf(" O");
  115.       else printf(" X");
  116.  
  117.    printf("16");
  118.    if (umove == 1)
  119.       printf("     Your color: White O\n");
  120.    else
  121.       if (umove == 2)
  122.      printf("     Your color: Black X\n");
  123.       else
  124.      printf("\n");
  125. /* row 15 to 11 */
  126.    for (i = 4; i < 9; i++)
  127.      {
  128.       ii = 19 - i;
  129.       printf("%2d",ii);
  130.  
  131.       for (j = 0; j < 19; j++)
  132.     if (p[i][j] == EMPTY)
  133.        printf(" -");
  134.     else if (p[i][j] == WHITE)
  135.         printf(" O");
  136.          else printf(" X");
  137.  
  138.       printf("%2d",ii);
  139.       if (i == 4)
  140.     {
  141.      if (mymove == 1)
  142.         printf("     My color:   White O\n");
  143.      else
  144.         if (mymove == 2)
  145.            printf("     My color:   Black X\n");
  146.         else
  147.            printf("\n");
  148.        }
  149.       else
  150.      if (i != 8)
  151.         printf("\n");
  152.      else
  153.         printf("     You have captured %d pieces\n", mk);
  154.      }
  155. /* row 10 */
  156.    printf("10");
  157.  
  158.    for (j = 0; j < 3; j++)
  159.      if (p[9][j] == EMPTY)
  160.     printf(" -");
  161.      else if (p[9][j] == WHITE)
  162.          printf(" O");
  163.       else printf(" X");
  164.  
  165.    if (p[9][3] == EMPTY)
  166.       printf(" +");
  167.    else if (p[9][3] == WHITE)
  168.        printf(" O");
  169.     else printf(" X");
  170.  
  171.    for (j = 4; j < 9; j++)
  172.      if (p[9][j] == EMPTY)
  173.     printf(" -");
  174.      else if (p[9][j] == WHITE)
  175.          printf(" O");
  176.       else printf(" X");
  177.  
  178.    if (p[9][9] == EMPTY)
  179.       printf(" +");
  180.    else if (p[9][9] == WHITE)
  181.        printf(" O");
  182.     else printf(" X");
  183.  
  184.    for (j = 10; j < 15; j++)
  185.      if (p[9][j] == EMPTY)
  186.     printf(" -");
  187.      else if (p[9][j] == WHITE)
  188.          printf(" O");
  189.       else printf(" X");
  190.  
  191.    if (p[9][15] == EMPTY)
  192.       printf(" +");
  193.    else if (p[9][15] == WHITE)
  194.        printf(" O");
  195.     else printf(" X");
  196.  
  197.    for (j = 16; j < 19; j++)
  198.      if (p[9][j] == EMPTY)
  199.     printf(" -");
  200.      else if (p[9][j] == WHITE)
  201.          printf(" O");
  202.       else printf(" X");
  203.  
  204.    printf("10");
  205.    printf("     I have captured %d pieces\n", uk);
  206. /* row 9 to 5 */
  207.    for (i = 10; i < 15; i++)
  208.      {
  209.       ii = 19 - i;
  210.       printf("%2d",ii);
  211.  
  212.       for (j = 0; j < 19; j++)
  213.     if (p[i][j] == EMPTY)
  214.        printf(" -");
  215.     else if (p[i][j] == WHITE)
  216.         printf(" O");
  217.          else printf(" X");
  218.  
  219.       printf("%2d",ii);
  220.       printf("\n");
  221.      }
  222. /* row 4 */
  223.    printf(" 4");
  224.  
  225.    for (j = 0; j < 3; j++)
  226.      if (p[15][j] == EMPTY)
  227.     printf(" -");
  228.      else if (p[15][j] == WHITE)
  229.          printf(" O");
  230.       else printf(" X");
  231.  
  232.    if (p[15][3] == EMPTY)
  233.       printf(" +");
  234.    else if (p[15][3] == WHITE)
  235.        printf(" O");
  236.     else printf(" X");
  237.  
  238.    for (j = 4; j < 9; j++)
  239.      if (p[15][j] == EMPTY)
  240.     printf(" -");
  241.      else if (p[15][j] == WHITE)
  242.          printf(" O");
  243.       else printf(" X");
  244.  
  245.    if (p[15][9] == EMPTY)
  246.       printf(" +");
  247.    else if (p[15][9] == WHITE)
  248.        printf(" O");
  249.     else printf(" X");
  250.  
  251.    for (j = 10; j < 15; j++)
  252.      if (p[15][j] == EMPTY)
  253.     printf(" -");
  254.      else if (p[15][j] == WHITE)
  255.          printf(" O");
  256.       else printf(" X");
  257.  
  258.    if (p[15][15] == EMPTY)
  259.       printf(" +");
  260.    else if (p[15][15] == WHITE)
  261.        printf(" O");
  262.     else printf(" X");
  263.  
  264.    for (j = 16; j < 19; j++)
  265.      if (p[15][j] == EMPTY)
  266.     printf(" -");
  267.      else if (p[15][j] == WHITE)
  268.          printf(" O");
  269.       else printf(" X");
  270.  
  271.    printf(" 4");
  272.    printf("\n");
  273. /* row 3 to 1 */
  274.    for (i = 16; i < 19; i++)
  275.      {
  276.       ii = 19 - i;
  277.       printf("%2d",ii);
  278.  
  279.       for (j = 0; j < 19; j++)
  280.     if (p[i][j] == EMPTY)
  281.        printf(" -");
  282.     else if (p[i][j] == WHITE)
  283.         printf(" O");
  284.          else printf(" X");
  285.  
  286.       printf("%2d",ii);
  287.       printf("\n");
  288.      }
  289.    printf("   A B C D E F G H J K L M N O P Q R S T\n\n");
  290.  }  /* end showboard */
  291.